package main

import (
	"flag"
)

var (
	port     = flag.Int("port", 50051, "The server port")
	schedule = flag.String("schedule", "affinity", "The schedule type")
)

func main() {
	flag.Parse()

	registerChan := make(chan RegisterBody, 5)
	finishChan := make(chan Task, 3)
	record := NewRecord(registerChan)
	server := NewServe(registerChan, finishChan)
	grpcServer := NewGRPCServe(server, *port)
	schedule := NewSchedule(*schedule, record, finishChan)

	go record.Register()
	go record.GC()
	go grpcServer.Lis()
	go schedule.Schedule()
	go schedule.Finish()

	wait := make(chan struct{})
	<-wait
}
